<?php 
/**
 * @author Tuan Ngo
 *
 */
class LogLine{
	
	//定数
	const TYPE_OPERATION = "OPERATION";
	const TYPE_ERROR = "ERROR";
	const TYPE_DEBUG = "DEBUG";
	const TYPE_UNKNOWN = "UNKNOWN";
	
	private $type;
	private $time;
	private $parts;
	
	public function LogLine($type){
		if($type == NULL)
			$this->type = LogLine::TYPE_UNKNOWN;
		$this->type = $type;
	}
	
	public function getCurrentTime(){
		$cur_time = date("Y/m/d H:i:s");
		
		return $cur_time;
	}
	
	/**
	 * @return the $type
	 */
	public function getType() {
		return $this->type;
	}

	/**
	 * @return the $time
	 */
	public function getTime() {
		return $this->time;
	}

	/**
	 * @return the $parts
	 */
	public function getParts() {
		return $this->parts;
	}

	/**
	 * @param field_type $type
	 */
	public function setType($type) {
		$this->type = $type;
	}

	/**
	 * @param field_type $time
	 */
	public function setTime($time = null) {
		if($time == null)
			$this->time = $this->getCurrentTime();
		else
			$this->time = $time;
	}

	/**
	 * @param field_type $parts
	 */
	public function setParts($parts) {
		$this->parts = $parts;
	}	
	
	public function addParts($part){
		$this->parts[] = $part;
	}
	
	public function getText(){
		$text = $this->type . ":";
		foreach ($this->parts as $part){
			$text .= $part . ":";	
		}
		$text .= $this->time;
		
		return $text;
	}
}
?>